#include "keyboard.h"
#include "ui_keyboard.h"
#include<QDebug>
keyboard::keyboard(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::keyboard)
{
    ui->setupUi(this);
    connect(ui->pushButton,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_2,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_3,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_4,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_5,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_6,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_7,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_8,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_9,&QPushButton::clicked,this,&keyboard::emit_number);
    connect(ui->pushButton_clear,&QPushButton::clicked,this,&keyboard::emit_clear);
    connect(ui->pushButton_return,&QPushButton::clicked,this,&keyboard::emit_close);

}

keyboard::~keyboard()
{
    delete ui;
}

void keyboard::emit_number()
{
    QPushButton *button = qobject_cast<QPushButton*>(sender());
     if (!button) return;

     bool ok;
     int number = button->text().toInt(&ok);
     qDebug()<<number;
     if (ok) {
         emit numberPressed(number);
     }
}
